#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>

using namespace std;

int main()
{
	int year = 0, month = 0, day = 0;
	int date[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
	while (cin >> year >> month >> day)
	{
		int sum = 0;
		for (int i = 0; i < month - 1; i++)
		{
			sum += date[i];
		}
		if (month > 2 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)))
		{
			sum = sum + day + 1;
		}
		else
		{
			sum += day;
		}
		cout << sum << endl;
	}
	return 0;
}